﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_BVDienDan : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    string hinhanh1;
    string hinhanh2;
    string hinhanh3;
    protected void upload_Click(object sender, EventArgs e)
    {
        HttpPostedFile file = FileUpload1.PostedFile;
        if (FileUpload1.HasFile == false && file.ContentLength > 800000)
        {
            lbthongbao.Text = "Vui lòng chọn file < 500KB";
        }
        else
            try
            {
                string strPath = Server.MapPath("Hinhanh/" + FileUpload1.FileName);
                FileUpload1.SaveAs(strPath);
                hinhanh1 = "Hinhanh/" + FileUpload1.FileName.ToString();
                lbthongbao.Text = "Upload thành công";
            }
            catch
            {
                lbthongbao.Text = "Upload thất bại";
            }
    }
    protected void upload2_Click(object sender, EventArgs e)
    {
        HttpPostedFile file = FileUpload1.PostedFile;
        if (FileUpload1.HasFile == false && file.ContentLength > 800000)
        {
            lbthongbao.Text = "Vui lòng chọn file < 500KB";
        }
        else
            try
            {
                string strPath = Server.MapPath("Hinhanh/" + FileUpload1.FileName);
                FileUpload1.SaveAs(strPath);
                hinhanh2 = "Hinhanh/" + FileUpload3.FileName.ToString();
                lbthongbao.Text = "Upload thành công";
            }
            catch
            {
                lbthongbao.Text = "Upload thất bại";
            }
    }
    protected void upload3_Click(object sender, EventArgs e)
    {
        HttpPostedFile file = FileUpload2.PostedFile;
        if (FileUpload1.HasFile == false && file.ContentLength > 800000)
        {
            lbthongbao.Text = "Vui lòng chọn file < 500KB";
        }
        else
            try
            {
                string strPath = Server.MapPath("Hinhanh/" + FileUpload3.FileName);
                FileUpload1.SaveAs(strPath);
                hinhanh3 = "Hinhanh/" + FileUpload3.FileName.ToString();
                lbthongbao.Text = "Upload thành công";
            }
            catch
            {
                lbthongbao.Text = "Upload thất bại";
            }
    }
    AccessData ac = new AccessData();
    bool oke = false;
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (chkBan.Checked)
        {
            oke = true;
        }
        ac.ExeCuteNonquery("INSERT INTO DienDan([TieuDe],[NoiDung],[GiaBan],[NguoiBan],[SDT],[Email],[ThoiGianDang],[LanXem],[PhamVi],[TheLoai],[DaBan],[Img1],[Img2],[Img3]) VALUES('" + txtTieuDe.Text + "','" + txtNoiDung.Text + "','" + int.Parse(txtGiaBan.Text) + "','" + txtHoTen.Text + "','" + txtSDT.Text + "','" + txtEmail.Text + "','" + "1/1/1993" + "','" + "0" + "','" + txtPhamVi.Text + "','" + oke+ "','" + false + "','" + hinhanh1 + "','" + hinhanh2 + "','" + hinhanh3 + "')");
    
        Response.Redirect("Deafault.aspx");
    }
}